class UsersController < ApplicationController
  # Be sure to include AuthenticationSystem in Application Controller instead
  include AuthenticatedSystem
  

  # render new.rhtml
  def new
    render :layout => false
  end

  def create
    cookies.delete :auth_token
    # protects against session fixation attacks, wreaks havoc with 
    # request forgery protection.
    # uncomment at your own risk
    # reset_session
    @user = User.new(params[:user])
    @user.save
    if @user.errors.empty?
      self.current_user = @user
      @users_count = User.count_by_sql("select count(1) from users")
      EmailQueue.create(:subject => "New user signed up!", :content => "New user => login: #{@user.login}, email: #{@user.email}. All currently signed up users count: #{@users_count}.", :recipient => SysConfig::EXCEPTION_NOTIFIER[:recipients], :content_type => "text/plain")
      redirect_back_or_default('/')
      flash[:notice] = "Thanks for signing up!"
    else
      render :action => 'new', :layout => false
    end
  end

end
